package com.cellulam.framework.core.exceptions;

import com.google.common.collect.Maps;

import java.util.Map;

public enum SystemErrorStatus implements ErrorStatus {
    SQL_SLOW(-10_001, "慢查询"),

    REQUEST_PARAMS_ERROR(-40_000, "请求参数错误"),
    REQUEST_PARAMS_EMPTY(-40_001, "请求参数为空"),
    USER_NOT_LOGIN(-40_101, "用户未登录"),
    TOKEN_EXPIRE(-40_102, "Token已失效"),
    RESOURCE_NOT_EXIST(-40_103, "数据不存在"),

    DATABASE_ERROR(-50_001, "数据库异常"),
    API_CALL_FAIL(-50_002, "接口调用失败"),
    SUPPLIER_EXCEPTION(-50_003, "供应商异常"),
    DUPLICATE_KEY(-50_004, "数据已存在"),
    SYS_ERROR(-50_500, "操作失败");

    private Map<Integer, SystemErrorStatus> map = Maps.newHashMap();

    private final int status;
    private final String message;

    SystemErrorStatus(int status, String message) {
        this.status = status;
        this.message = message;
        this.map.put(status, this);
    }

    @Override
    public String getMessage() {
        return this.message;
    }

    @Override
    public Map<Integer, SystemErrorStatus> getErrorMaps() {
        return this.map;
    }

    @Override
    public int getStatus() {
        return this.status;
    }

}
